#include<iostream>
using namespace std;

double calculate(double a, double b, double (*pf)(double m, double n));
double add(double a, double b);
double minus_(double a, double b);
double multiply(double a, double b);

int main(){
    // 使用指针数组调用
    double (*pf[3])(double, double) = {add, minus_, multiply};
    double a = 2.0, b = 3.0;
    for (int i = 0; i < 3; i++){
        double m = calculate(a, b, pf[i]);
        cout << "m = " << m << endl;
    }
}

double add(double a, double b){
    return a + b;
}

double minus_(double a, double b){
    return a - b;
}

double multiply(double a, double b){
    return a * b;
}

double calculate(double a, double b, double (*pf)(double m, double n)){
    return pf(a, b);
}